package cn.sumpu.app.guoguojie.domain;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import cn.sumpu.app.guoguojie.constant.Constellation;
import cn.sumpu.app.guoguojie.constant.FamilyRole;
import cn.sumpu.app.guoguojie.constant.Sex;
import cn.sumpu.app.guoguojie.util.Common;
import cn.sumpu.app.guoguojie.util.DateUtil;

public class Member implements Serializable {

    private static final long      serialVersionUID = -886691862938169559L;

    private String                 family;
    private String                 identifier;
    private String                 username;
    private String                 nickname;
    // 头像URL
    private String                 avatar;
    private String                 password;
    private String                 salt;
    private String                 email;
    private String                 activeEmail;
    private String                 mobilephone;
    private String                 role;
    private Boolean                isHost;
    private Boolean                isActive;
    private String                 activeCode;
    // 重置密码的标记
    private String                 resetPassword;

    private String                 imageServer;
    private Date                   gmtCreated;
    private Date                   gmtModified;

    private String                 sex;
    private String                 birthday;
    private String                 constellation;

    private String                 owner;
    private String                 ownerType;

    private Integer                shareProductCount;                      //分享宝贝数
    private Integer                loveCount        = 0;                   //粉丝数
    private Boolean                isHasBaby;
    private String                 registerIP;
    private Date                   registerTime;
    private String                 loginIP;
    private Date                   loginTime;
    private Integer                loginCount;
    private Integer                doingCount;
    private Integer                replyCount;
    private Integer                pictorialCount;
    private Long                   totalOnlineTime;
    private Boolean                enabled          = true;                //是否被屏蔽
    private String                 approveStatus;
    private String                 approveReason;
    private String                 approveImg;
    private Date                   approveDate;

    private MemberDetail           memberDetail;
    private List<MemberOutAccount> outAccountList;                         //外部帐号
    private Account                account;
    private Integer                fansCount        = 0;                   //粉丝数
    private Integer                followCount      = 0;                   //关注数
    private Family                 familyObj;

    private Boolean                isSon;
    private Integer                noReadMsg;

    public Integer getNoReadMsg() {
        return noReadMsg;
    }

    public void setNoReadMsg(Integer noReadMsg) {
        this.noReadMsg = noReadMsg;
    }

    public Boolean getIsSon() {
        return isSon;
    }

    public void setIsSon(Boolean isSon) {
        this.isSon = isSon;
    }

    public Boolean getIsHasBaby() {
        return isHasBaby;
    }

    public Date getRegisterTime() {
        return registerTime;
    }

    public void setRegisterTime(Date registerTime) {
        this.registerTime = registerTime;
    }

    public String getLoginIP() {
        return loginIP;
    }

    public void setLoginIP(String loginIP) {
        this.loginIP = loginIP;
    }

    public Date getLoginTime() {
        return loginTime;
    }

    public void setLoginTime(Date loginTime) {
        this.loginTime = loginTime;
    }

    public Integer getLoginCount() {
        return loginCount;
    }

    public void setLoginCount(Integer loginCount) {
        this.loginCount = loginCount;
    }

    public String getRegisterIP() {
        return registerIP;
    }

    public void setRegisterIP(String registerIP) {
        this.registerIP = registerIP;
    }

    public void setIsHasBaby(Boolean isHasBaby) {
        this.isHasBaby = isHasBaby;
    }

    public Integer getFansCount() {
        return fansCount;
    }

    public void setFansCount(Integer fansCount) {
        this.fansCount = fansCount;
    }

    public Integer getShareProductCount() {
        return shareProductCount;
    }

    public void setShareProductCount(Integer shareProductCount) {
        this.shareProductCount = shareProductCount;
    }

    public String getResetPassword() {
        return resetPassword;
    }

    public void setResetPassword(String resetPassword) {
        this.resetPassword = resetPassword;
    }

    public String getConstellation() {
        return constellation;
    }

    public String getConstellationLabel() {
        return Constellation.getLabelByValue(this.constellation);
    }

    public void setConstellation(String constellation) {
        this.constellation = constellation;
    }

    public String getFamily() {
        return family;
    }

    public void setFamily(String family) {
        this.family = family;
    }

    public String getIdentifier() {
        return identifier;
    }

    public void setIdentifier(String identifier) {
        this.identifier = identifier;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getSalt() {
        return salt;
    }

    public void setSalt(String salt) {
        this.salt = salt;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getMobilephone() {
        return mobilephone;
    }

    public void setMobilephone(String mobilephone) {
        this.mobilephone = mobilephone;
    }

    public String getRole() {
        return role;
    }

    public void setRole(String role) {
        this.role = role;
    }

    public Boolean getIsHost() {
        return isHost;
    }

    public void setIsHost(Boolean isHost) {
        this.isHost = isHost;
    }

    public Boolean getIsActive() {
        return isActive;
    }

    public void setIsActive(Boolean isActive) {
        this.isActive = isActive;
    }

    public Date getGmtCreated() {
        return gmtCreated;
    }

    public void setGmtCreated(Date gmtCreated) {
        this.gmtCreated = gmtCreated;
    }

    public Date getGmtModified() {
        return gmtModified;
    }

    public void setGmtModified(Date gmtModified) {
        this.gmtModified = gmtModified;
    }

    public static long getSerialversionuid() {
        return serialVersionUID;
    }

    public Family getFamilyObj() {
        return familyObj;
    }

    public void setFamilyObj(Family familyObj) {
        this.familyObj = familyObj;
    }

    public MemberDetail getMemberDetail() {
        return memberDetail;
    }

    public void setMemberDetail(MemberDetail memberDetail) {
        this.memberDetail = memberDetail;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getBirthday() {
        return birthday;
    }

    public void setBirthday(String birthday) {
        this.birthday = birthday;
    }

    public String getActiveCode() {
        return activeCode;
    }

    public void setActiveCode(String activeCode) {
        this.activeCode = activeCode;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    public String getNickname() {
        return nickname;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public String getAvatar() {
        return avatar;
    }

    public String getAge() {
        return DateUtil.getAge(birthday);
    }

    public String getRoleLabel() {
        return FamilyRole.getLabelByValue(this.role);
    }

    public String getSexLabel() {
        return Sex.getLabelByValue(this.sex);
    }

    public String getImageServer() {
        return imageServer;
    }

    public void setImageServer(String imageServer) {
        this.imageServer = imageServer;
    }

    // 更新session里面的会员的详细信息
    public static void setSessionMemberDetail(Member member, MemberDetail memberDetail) {
        MemberDetail d = member.getMemberDetail();
        if (Common.notNull(memberDetail.getBlood())) {
            d.setBlood(memberDetail.getBlood());
        }
        if (Common.notNull(memberDetail.getProfile())) {
            d.setProfile(memberDetail.getProfile());
        }
        if (Common.notNull(memberDetail.getIntroduction())) {
            d.setIntroduction(memberDetail.getIntroduction());
        }
        if (Common.notNull(memberDetail.getEmail())) {
            d.setEmail(memberDetail.getEmail());
        }
        if (Common.notNull(memberDetail.getPhone())) {
            d.setPhone(memberDetail.getPhone());
        }
        if (Common.notNull(memberDetail.getMobilephone())) {
            d.setMobilephone(memberDetail.getMobilephone());
        }
        if (Common.notNull(memberDetail.getQq())) {
            d.setQq(memberDetail.getQq());
        }
        if (Common.notNull(memberDetail.getMsn())) {
            d.setMsn(memberDetail.getMsn());
        }
        if (Common.notNull(memberDetail.getProvince())) {
            d.setProvince(memberDetail.getProvince());
        }
        if (Common.notNull(memberDetail.getCity())) {
            d.setCity(memberDetail.getCity());
        }
        if (Common.notNull(memberDetail.getCounty())) {
            d.setCounty(memberDetail.getCounty());
        }
        if (Common.notNull(memberDetail.getAddress())) {
            d.setAddress(memberDetail.getAddress());
        }
        if (Common.notNull(memberDetail.getZipcode())) {
            d.setZipcode(memberDetail.getZipcode());
        }
        if (Common.notNull(memberDetail.getBirthProvince())) {
            d.setBirthProvince(memberDetail.getBirthProvince());
        }
        if (Common.notNull(memberDetail.getBirthCity())) {
            d.setBirthCity(memberDetail.getBirthCity());
        }
        if (Common.notNull(memberDetail.getBirthCounty())) {
            d.setBirthCounty(memberDetail.getBirthCounty());
        }
        if (Common.notNull(memberDetail.getBirthAddress())) {
            d.setBirthAddress(memberDetail.getBirthAddress());
        }
        if (Common.notNull(memberDetail.getBirthZipcode())) {
            d.setBirthZipcode(memberDetail.getBirthZipcode());
        }
        if (Common.notNull(memberDetail.getBirthday())) {
            d.setBirthday(memberDetail.getBirthday());
        }
        if (Common.notNull(memberDetail.getSex())) {
            d.setSex(memberDetail.getSex());
        }
        if (Common.notNull(memberDetail.getProvinceCode())) {
            d.setProvinceCode(memberDetail.getProvinceCode());
        }
        if (Common.notNull(memberDetail.getCityCode())) {
            d.setCityCode(memberDetail.getCityCode());
        }
        if (Common.notNull(memberDetail.getCountyCode())) {
            d.setCountyCode(memberDetail.getCountyCode());
        }
        if (Common.notNull(memberDetail.getTown())) {
            d.setTown(memberDetail.getTown());
        }
        if (Common.notNull(memberDetail.getTownCode())) {
            d.setTownCode(memberDetail.getTownCode());
        }
        if (Common.notNull(memberDetail.getBirthTown())) {
            d.setBirthTown(memberDetail.getBirthTown());
        }
        if (Common.notNull(memberDetail.getBirthTownCode())) {
            d.setBirthTownCode(memberDetail.getBirthTownCode());
        }
        if (Common.notNull(memberDetail.getBirthCountyCode())) {
            d.setBirthCountyCode(memberDetail.getBirthCountyCode());
        }
        if (Common.notNull(memberDetail.getBirthProvinceCode())) {
            d.setBirthProvinceCode(memberDetail.getBirthProvinceCode());
        }
        if (Common.notNull(memberDetail.getBirthCityCode())) {
            d.setBirthCityCode(memberDetail.getBirthCityCode());
        }
    }

    // 更新session里面的会员的家的信息
    public static void setSessionMemberFamiyInfo(Member member, Family family) {
        Family f = member.getFamilyObj();
        if (Common.notNull(family.getNickname())) {
            f.setNickname(family.getNickname());
        }
        if (Common.notNull(family.getAvatar())) {
            f.setAvatar(family.getAvatar());
        }
        if (Common.notNull(family.getProvince())) {
            f.setProvince(family.getProvince());
        }
        if (Common.notNull(family.getCity())) {
            f.setCity(family.getCity());
        }
        if (Common.notNull(family.getCounty())) {
            f.setCounty(family.getCounty());
        }
        if (Common.notNull(family.getAddress())) {
            f.setAddress(family.getAddress());
        }
        if (Common.notNull(family.getIntroduction())) {
            f.setIntroduction(family.getIntroduction());
        }
        if (!Common.empty(family.getIntegral())) {
            f.setIntegral(family.getIntegral());
        }
        if (!Common.empty(family.getIsActive())) {
            f.setIsActive(family.getIsActive());
        }
        if (Common.notNull(family.getImageServer())) {
            f.setImageServer(family.getImageServer());
        }
        if (Common.notNull(family.getSkin())) {
            f.setSkin(family.getSkin());
        }
        if (Common.notNull(family.getTown())) {
            f.setTown(family.getTown());
        }
        if (Common.notNull(family.getProvinceCode())) {
            f.setProvinceCode(family.getProvinceCode());
        }
        if (Common.notNull(family.getCityCode())) {
            f.setCityCode(family.getCityCode());
        }
        if (Common.notNull(family.getCountyCode())) {
            f.setCountyCode(family.getCountyCode());
        }
        if (Common.notNull(family.getTownCode())) {
            f.setTownCode(family.getTownCode());
        }
    }

    // 更新session里面的会员的信息
    public static void setSessionMemberInfo(Member sessionMember, Member member) {
        if (Common.notNull(member.getUsername())) {
            sessionMember.setUsername(member.getUsername());
        }
        if (Common.notNull(member.getNickname())) {
            sessionMember.setNickname(member.getNickname());
        }
        if (Common.notNull(member.getAvatar())) {
            sessionMember.setAvatar(member.getAvatar());
        }
        if (Common.notNull(member.getPassword())) {
            sessionMember.setPassword(member.getPassword());
        }
        if (Common.notNull(member.getSalt())) {
            sessionMember.setSalt(member.getSalt());
        }

        if (Common.notNull(member.getEmail())) {
            sessionMember.setEmail(member.getEmail());
        }
        if (Common.notNull(member.getMobilephone())) {
            sessionMember.setMobilephone(member.getMobilephone());
        }
        if (Common.notNull(member.getRole())) {
            sessionMember.setRole(member.getRole());
        }
        if (!Common.empty(member.getIsHost())) {
            sessionMember.setIsHost(member.getIsHost());
        }
        if (!Common.empty(member.getIsActive())) {
            sessionMember.setIsActive(member.getIsActive());
        }
    }

    public String getOwner() {
        return owner;
    }

    public void setOwner(String owner) {
        this.owner = owner;
    }

    public String getOwnerType() {
        return ownerType;
    }

    public void setOwnerType(String ownerType) {
        this.ownerType = ownerType;
    }

    //得到宝宝的年龄精确到周
    public String getAgeWeek() {
        return DateUtil.getAgeWeek(birthday);
    }

    //得到宝宝的生日转换成Date格式
    public Date getBirthdayDate() {
        if (Common.emptyStr(birthday)) {
            return null;
        }
        return DateUtil.getBirthdayDate(birthday);
    }

    public List<MemberOutAccount> getOutAccountList() {

        return outAccountList;
    }

    public void setOutAccountList(List<MemberOutAccount> outAccountList) {
        this.outAccountList = outAccountList;
    }

    public Long getTotalOnlineTime() {
        return totalOnlineTime;
    }

    public void setTotalOnlineTime(Long totalOnlineTime) {
        this.totalOnlineTime = totalOnlineTime;
    }

    public Integer getDoingCount() {
        return doingCount;
    }

    public void setDoingCount(Integer doingCount) {
        this.doingCount = doingCount;
    }

    public Integer getReplyCount() {
        return replyCount;
    }

    public void setReplyCount(Integer replyCount) {
        this.replyCount = replyCount;
    }

    public Integer getPictorialCount() {
        return pictorialCount;
    }

    public void setPictorialCount(Integer pictorialCount) {
        this.pictorialCount = pictorialCount;
    }

    public Boolean getEnabled() {
        return enabled;
    }

    public void setEnabled(Boolean enabled) {
        this.enabled = enabled;
    }

    public String getApproveStatus() {
        return approveStatus;
    }

    public void setApproveStatus(String approveStatus) {
        this.approveStatus = approveStatus;
    }

    public String getApproveReason() {
        return approveReason;
    }

    public void setApproveReason(String approveReason) {
        this.approveReason = approveReason;
    }

    public Date getApproveDate() {
        return approveDate;
    }

    public void setApproveDate(Date approveDate) {
        this.approveDate = approveDate;
    }

    public String getApproveImg() {
        return approveImg;
    }

    public void setApproveImg(String approveImg) {
        this.approveImg = approveImg;
    }

    public Integer getLoveCount() {
        return loveCount;
    }

    public void setLoveCount(Integer loveCount) {
        this.loveCount = loveCount;
    }

    public Integer getFollowCount() {
        return followCount;
    }

    public void setFollowCount(Integer followCount) {
        this.followCount = followCount;
    }

    public String getActiveEmail() {
        return activeEmail;
    }

    public void setActiveEmail(String activeEmail) {
        this.activeEmail = activeEmail;
    }

    public Account getAccount() {
        return account;
    }

    public void setAccount(Account account) {
        this.account = account;
    }

}
